#include "cdbnlib.h"
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
	// Create a top layer of 5 neurons
	// and a bottom layer of 4 neurons
	dl_layer_t inputlayer, hiddenlayer;
	dl_create_layer(&hiddenlayer,5);
	dl_create_layer(&inputlayer, 8);

	// Create a RBM from those layers
	dl_rbm_t myrbm;
	dl_create_rbm(&myrbm,&inputlayer,&hiddenlayer);

	// Some data to be trained in the input neurons
	double data[] = {0.18757,0.33604,0.55087,0.96215,0.18757,0.33604,0.55087,0.96215};

	// Do a training for 20 epochs using the same
	// data with learning rate of 0.1 and moment of 0.5
	int i;
	for (i = 0 ; i < 20 ; ++i)
	{
		dl_rbm_train(&myrbm, data, 0.1, 0.5, 1.0, 1.0);
		printf("error=%f\n",sqrt(myrbm.accerr));
	}

	// De-allocate the memory
	dl_del_rbm(&myrbm);
	dl_del_layer(&inputlayer);
	dl_del_layer(&hiddenlayer);
}

